
#include <iostream>
#include <vector>
#include <cmath>

const int N = 50;
typedef long long LL;

using namespace std;

vector<int> b;
LL a[N];
bool st[N];

LL n, k;
LL ret = 0;

void dfs(int pos)
{
	if (b.size() == k)
	{
		LL sum = 0;
		for (auto x : b)
		{
			sum += x;
		}
		
		if (sum <= 1) return; 
		for (int i = 2; i <= sqrt(sum); i++)
		{
			if (sum % i == 0) return;
		}
		
		ret++;
		return; 
	} 
	
	for (int i = pos; i <= n; i++)
	{
		if (st[i] == true) continue;
		b.push_back(a[i]);
		st[i] = true;
		dfs(i);
		b.pop_back();
        st[i] = false;
	}
}

int main()
{
	cin >> n >> k;
	for (int i = 1; i <= n ;i++) cin >> a[i];
	
	dfs(1);
	
	cout << ret;
	
	return 0;
}
